package cuit.cx.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class LoginOrRegisterAct extends TabActivity {
    /** Called when the activity is first created. */
	
	private RadioGroup radioGroup;
	private TabHost theHost;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_or_register);
        findView();
        initView();
    }
    
 void findView(){
    	
    	theHost = getTabHost();
    	radioGroup = (RadioGroup) findViewById(R.id.login_or_register_rg);
    	
    }
    
    void initView(){
    	
    	theHost.addTab(theHost.newTabSpec("userlogin").setIndicator("userlogin").setContent(new Intent(this, LoginUserAct.class)));
    	theHost.addTab(theHost.newTabSpec("businesslogin").setIndicator("businesslogin").setContent(new Intent(this, LoginBusinessAct.class)));
    	theHost.addTab(theHost.newTabSpec("register").setIndicator("register").setContent(new Intent(this, RegisterAct.class)));
    	
    	radioGroup.check(R.id.login_user_rb);
    	radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup arg0, int checkId) {
				
				switch (checkId) {
				case R.id.login_user_rb:
					theHost.setCurrentTabByTag("userlogin");
					System.out.println("--------login_user_rb---------------");
					break;
				case R.id.login_business_rb:
					theHost.setCurrentTabByTag("businesslogin");
					break;
				case R.id.register_rb:
					theHost.setCurrentTabByTag("register");
					break;

				default:
					break;
				}
				
			}
		});
    	
    }
}
